//
//  ImageTableViewCell.m
//  GentlemanAnime
//
//  Created by dlios on 15-6-29.
//  Copyright (c) 2015年 lanou3g.com 蓝欧科技. All rights reserved.
//

#import "ImageTableViewCell.h"
#import "UIImageView+WebCache.h"

#define WIDTH self.contentView.frame.size.width
#define HEIGHT self.contentView.frame.size.height

@interface ImageTableViewCell ()

@property(nonatomic, retain)UIImageView *upView;
@property(nonatomic, retain)UIView *downLabelBackView;
@property(nonatomic, retain)UIImageView *heibaiImageView;

@end

@implementation ImageTableViewCell

- (void)dealloc
{
    [_heibaiImageView release];
    [_downLabelBackView release];
    [_upView release];
    [_backView release];
    [_upImageView release];
    [_downLabel release];
    [_countImageView release];
    [_likeImageView release];
    [_countLabel release];
    [_likeLabel release];
    [super dealloc];
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.contentView.backgroundColor = [UIColor whiteColor];
    
        self.backView = [[UIView alloc] init];
        self.backView.layer.cornerRadius = 10;
        self.backView.clipsToBounds = YES;
        [self.contentView addSubview:self.backView];
        [_backView release];
        
        self.upImageView = [[UIImageView alloc] init];
        // 让图片显示原来比例(contentMode是UIView的属性)
        self.upImageView.contentMode = UIViewContentModeScaleAspectFill;
        [self.backView addSubview:self.upImageView];
        [_upImageView release];
 
        self.downLabelBackView = [[UILabel alloc] init];
        [self.upImageView addSubview:self.downLabelBackView];
        [_downLabelBackView release];
        
        self.downLabel = [[UILabel alloc] init];
        [self.backView addSubview:self.downLabel];
        self.downLabel.textColor = [UIColor whiteColor];
        self.downLabel.font = [UIFont systemFontOfSize:15];
        self.downLabel.backgroundColor = [UIColor clearColor];
        [_downLabel release];
        
        self.countImageView = [[UIImageView alloc] init];
        self.countImageView.image = [UIImage imageNamed:@"tupian"];
        [self.backView addSubview:self.countImageView];
        [_countImageView release];
        
        self.likeImageView = [[UIImageView alloc] init];
        self.likeImageView.image = [UIImage imageNamed:@"shixin"];
        [self.backView addSubview:self.likeImageView];
        [_likeImageView release];
        
        self.countLabel = [[UILabel alloc] init];
        self.countLabel.textColor = [UIColor whiteColor];
        self.countLabel.font = [UIFont systemFontOfSize:14];
        [self.backView addSubview:self.countLabel];
        [_countLabel release];
        
        self.likeLabel = [[UILabel alloc] init];
        self.likeLabel.textColor = [UIColor whiteColor];
        self.likeLabel.font = [UIFont systemFontOfSize:14];
        [self.backView addSubview:self.likeLabel];
        [_likeLabel release];
        
        self.heibaiImageView = [[UIImageView alloc] init];
        [self.upImageView addSubview:self.heibaiImageView];
        self.heibaiImageView.image = [UIImage imageNamed:@"大图蒙板"];
        [_heibaiImageView release];
        
        self.upView = [[UIImageView alloc] init];
        [self.upImageView addSubview:self.upView];
        self.upView.image = [UIImage imageNamed:@"大图蒙板上"];
        [_upView release];
    }
    return self;
}

- (void)layoutSubviews
{
    [super layoutSubviews];
    self.backView.frame = CGRectMake(5, 5, WIDTH - 10, HEIGHT - 10);
    
    self.upImageView.frame = CGRectMake(0, 0, WIDTH - 10, HEIGHT - 10);
    self.heibaiImageView.frame = CGRectMake(0, HEIGHT - 50, self.upImageView.frame.size.width, 50);
    self.upView.frame = CGRectMake(0, 0, WIDTH - 10, 30);
    
    self.downLabelBackView.frame = CGRectMake(0, HEIGHT - 40, WIDTH - 10, 30);
    self.downLabel.frame = CGRectMake(5, HEIGHT - 40, WIDTH - 15, 30);
    self.countImageView.frame = CGRectMake(WIDTH - 90, 5, 15, 15);
    self.countLabel.frame = CGRectMake(WIDTH - 72, 5, 30, 15);
    self.likeImageView.frame = CGRectMake(WIDTH - 50, 5, 15, 15);
    self.likeLabel.frame = CGRectMake(WIDTH - 32, 5, 30, 15);
    
}





/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
